package com.example.mysdktest.activities;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.Shape;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.example.mysdktest.R;
import com.example.mysdktest.base.BaseActivity;
import com.xm9m.ibczy.dsp.utils.AntLog;

/**
 * Created by baichuan on 2016/11/24.
 */

public class Test006 extends BaseActivity implements View.OnClickListener {
    private ImageView img;
    private Button obt;

    private String newImg = "http://img4.imgtn.bdimg.com/it/u=2317499888,864114656&fm=21&gp=0.jpg";

    @Override
    public int getLaout() {
        return R.layout.ac_layout006;
    }

    @Override
    public void initView() {
        img = (ImageView) findViewById(R.id.ac_test06_img_01);
        obt = (Button) findViewById(R.id.ac_test006_obt01);

    }

    @Override
    public void initData() {

    }

    @Override
    public void initListener() {
        obt.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ac_test006_obt01:
                setShape();
                break;
        }
    }

    private void setShape() {
        AntLog.i("ant set drawable");
        ShapeDrawable drawable = new ShapeDrawable(new Shape() {
            @Override
            public void draw(Canvas canvas, Paint paint) {
                paint.setColor(Color.RED);
                paint.setAntiAlias(true);
                paint.setStyle(Paint.Style.FILL);
                canvas.drawCircle(100, 100, 50, paint);
            }
        });

        img.setImageDrawable(drawable);
    }
}
